package com.framework
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.EventPhase;
	import flash.geom.Point;
	import flash.text.TextField;
	
	public class BasicPage extends MovieClip
	{
		public var prevPage:int;
		public var nextPage:int;
		public var currPage:int;
		
		public var id:int;
		public var pos:Point;
		
		public var isRemain = false;//该页面时否要移除；
		
		//test
		public var infoText:TextField = new TextField;
		
		protected const margin:int = 50;// buttons margin
		protected const origin_x:int = 100;//buttons original x
		protected const origin_y:int = 40;//buttons original y
		
		
		public function BasicPage()
		{
			infoText.text = "BasicPage Constructed";
		//	addChild(infoText);
			addEventListener(Event.ADDED_TO_STAGE,init);
			addEventListener(Event.ENTER_FRAME,update);
			super();
		
		}
		
		public function update(e:Event):void
		{
			
		}
		
		public function init(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE,init);
		}
		
		
		public function addButtonByName(btnName:int,btnId:int):BasicButton
		{
			var temp_y:int = origin_y + margin*btnId;
			var btn:BasicButton = addButton(btnName,btnId,origin_x,temp_y );
			return btn;
			
			
		}
		
		public function addButton(btnName,btnId:int,val_x:int,val_y:int):BasicButton
		{
			var btn:BasicButton = new BasicButton;
			
			btn.id = btnId;
			btn.x = val_x;
			btn.y = val_y;
			btn.btnName = btnName;
			
			switch(btnName)
			{
				case ButtonInfo.BUTTON_PLAY:
					btn.txtButtonName.text = "PLAY";
					break;
				case ButtonInfo.BUTTON_HELP:
					btn.txtButtonName.text = "HELP";
					break;
				case ButtonInfo.BUTTON_STAGE_MODE:
					btn.txtButtonName.text = "STAGE MODE";
					break;
				case ButtonInfo.BUTTON_SURVIVE_MODE:
					btn.txtButtonName.text = "CHALLENGE";
					break;
				case ButtonInfo.BUTTON_KIOSK:
					btn.txtButtonName.text = "KIOSK";
					break;
				case ButtonInfo.BUTTON_BILLBOARD:
					btn.txtButtonName.text = "BILLBOARD";
					break;
				case ButtonInfo.BUTTON_BACK:
					btn.txtButtonName.text = "BACK"
					break;
				case ButtonInfo.BUTTON_WAREHOUSE:
					btn.txtButtonName.text = "WAREHOUSE"
					break;
				case ButtonInfo.BUTTON_PAUSE:
					btn.txtButtonName.text = "PAUSE"
					break;
				case ButtonInfo.BUTTON_REPLAY:
					btn.txtButtonName.text = "REPLAY"
					break;
				
			}
			
			this.addChild(btn);
			btn.addButtonEventListener();			
			return btn;
		}
	}
}